package sctu.edu.java.year2016.team03.liyouhong.day20160521.chapter4_2;

/**
 * Created by Administrator on 2016/5/21 0021.
 * 2.编写java程序，应用for循环打印菱形。
 */
public class Diamond {
    public static void main(String[] args) {
        int num=8;
        for(int i=0;i<num/2+1;i++) {
            for (int j = num / 2 ; j > i ; j--) {
                System.out.print(" ");
            }

            for (int j = 0; j < 2 * i+1; j++)
            { if(j==0||j==2*i)
                System.out.print("*");
                else
                System.out.print(" ");
        }
        System.out.println("");
    }
    for(int i=num/2;i<num;i++){
        for(int j=0;j<i+1-num/2;j++){
            System.out.print(" ");
        }
        for(int j=0;j<2*num-1-i*2;j++){
           if(j==0||j==2*(num-i-1))
               System.out.print("*");
            else
               System.out.print(" ");
        }
        System.out.println("");
    }
}


}
